
//
//  UIButton + Extension.swift
//  微博项目
//
//  Created by mac on 16/1/17.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

extension UIButton
{
//指定背景图片 和按钮的图片的构造函数
    convenience init(imageName: String,backImageName: String){
    self.init()
        setImage(UIImage(named: imageName), forState: .Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: .Highlighted)
        
        //指定大小
        sizeToFit()
 
    }
    
    convenience init(title: String,fontSize: CGFloat,color: UIColor,backImageName: String){
    self.init()
        
        setTitle(title, forState: .Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        setTitleColor(color, forState: .Normal)
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
    
    }

}